import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDHuangXiaoxiDialogue {
	/**ID*/
	id,
	/**描述*/
	desc,
	/**喊话类型（1为随机喊话,2为章节喊话，同章节喊话随机）*/
	dialogueType,
	/**所属章节*/
	chapter,

	/**枚举数量*/
	EnumCount
}



export class CDHuangXiaoxiDialogue{
	/**ID*/
	public id: number;
	/**描述*/
	public desc: number;
	/**喊话类型（1为随机喊话,2为章节喊话，同章节喊话随机）*/
	public dialogueType: number;
	/**所属章节*/
	public chapter: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDHuangXiaoxiDialogue.id: return this.id;
			case E_CDHuangXiaoxiDialogue.desc: return this.desc;
			case E_CDHuangXiaoxiDialogue.dialogueType: return this.dialogueType;
			case E_CDHuangXiaoxiDialogue.chapter: return this.chapter;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDHuangXiaoxiDialogue.id: this.id = v; break;
			case E_CDHuangXiaoxiDialogue.desc: this.desc = v; break;
			case E_CDHuangXiaoxiDialogue.dialogueType: this.dialogueType = v; break;
			case E_CDHuangXiaoxiDialogue.chapter: this.chapter = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDHuangXiaoxiDialogue> = new HashMap<number, CDHuangXiaoxiDialogue>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDHuangXiaoxiDialogue[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDHuangXiaoxiDialogue();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dialogueType = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].chapter = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDHuangXiaoxiDialogue{
		return this.datas ? this.datas.get(id) : null;
	}
}
